//
//  ScrollViewController.m
//  LOL
//
//  Created by lanou3g on 15/11/18.
//  Copyright © 2015年 syx. All rights reserved.
//

#import "ScrollViewController.h"
#import "MBProgressHUD.h"

@interface ScrollViewController ()<UIWebViewDelegate>
@property (nonatomic,strong) UIWebView * webView;
@property (nonatomic,strong) MBProgressHUD *HUD;
@end

@implementation ScrollViewController

-(UIWebView *)webView{
    if (!_webView) {
        _webView = nil;
        _webView = [[UIWebView alloc]initWithFrame:self.view.bounds];
        self.HUD = [MBProgressHUD showHUDAddedTo:self.webView animated:YES];
    }
    return _webView;
}

- (void)viewWillAppear:(BOOL)animated{
    [super viewWillAppear:animated];
}

- (void)viewDidLoad {
    [super viewDidLoad];
    self.view.backgroundColor = [UIColor whiteColor];
    
    UIView * view = [[UIView alloc]initWithFrame:[UIScreen mainScreen].bounds];
    view.backgroundColor = [UIColor whiteColor];
    [self.view addSubview:view];
    [view addSubview:self.webView];
    
    self.webView.delegate = self;
    
    [self updateView];
    
    self.navigationItem.leftBarButtonItem = [[UIBarButtonItem alloc]initWithTitle:@"返回" style:UIBarButtonItemStyleDone target:self action:@selector(leftButtonAction:)];
    // Do any additional setup after loading the view.
}

// webView加载轮播图详情页面
- (void)updateView{
    NSURL *url = [NSURL URLWithString:self.url];
    NSURLRequest * request = [NSURLRequest requestWithURL:url];
    [self.webView loadRequest:request];
}

// webView代理方法
- (void)webViewDidFinishLoad:(UIWebView *)webView{
    [self.HUD performSelectorOnMainThread:@selector(hide:) withObject:nil waitUntilDone:YES];
}

// 左按钮
- (void)leftButtonAction:(UIBarButtonItem *)button{
    [self.navigationController popViewControllerAnimated:YES];
}

- (void)didReceiveMemoryWarning {
    [super didReceiveMemoryWarning];
    // Dispose of any resources that can be recreated.
}

/*
#pragma mark - Navigation

// In a storyboard-based application, you will often want to do a little preparation before navigation
- (void)prepareForSegue:(UIStoryboardSegue *)segue sender:(id)sender {
    // Get the new view controller using [segue destinationViewController].
    // Pass the selected object to the new view controller.
}
*/

@end
